<template>
	<view class="content">
		<view class="act-type-choose">
			<view class="each-column">
				<navigator url="../one-kind/one-kind">
					<view class="each-one">
						<image src="../../../static/swiper/4.jpg"></image>
						<text>音乐馆</text>
					</view>
				</navigator>
				
				<view class="each-one">
					<image src="../../../static/swiper/4.jpg"></image>
					<text>音乐馆</text>
				</view>
			</view>
			<view class="each-column">
				<view class="each-one">
					<image src="../../../static/swiper/4.jpg"></image>
					<text>音乐馆</text>
				</view>
				<view class="each-one">
					<image src="../../../static/swiper/4.jpg"></image>
					<text>音乐馆</text>
				</view>
			</view>
			<view class="each-column">
				<view class="each-one">
					<image src="../../../static/swiper/4.jpg"></image>
					<text>音乐馆</text>
				</view>
				<view class="each-one">
					<image src="../../../static/swiper/4.jpg"></image>
					<text>音乐馆</text>
				</view>
			</view>
			<view class="each-column">
				<view class="each-one">
					<image src="../../../static/swiper/4.jpg"></image>
					<text>音乐馆</text>
				</view>
				<view class="each-one">
					<image src="../../../static/swiper/4.jpg"></image>
					<text>音乐馆</text>
				</view>
			</view>
			<view class="each-column">
				<view class="each-one">
					<image src="../../../static/swiper/4.jpg"></image>
					<text>音乐馆</text>
				</view>
				<view class="each-one">
					<image src="../../../static/swiper/4.jpg"></image>
					<text>音乐馆</text>
				</view>
			</view>
		</view>
		<view class="choose-new-hot">
			<text v-for="(item,index) in chooseItems" @click="onClickItem" :id="index"  class="new-hot" :class="chooseIndex == index ? 'new-hot-active' : ''">{{item}}</text>
		</view>
		<view class="new" v-if="chooseIndex == 0">
			<view class="interest-card" v-for="(item,index) in newAct">
				<view class="img"><image :src="item.actImg"></image></view>
				<view class="text">
					<view class="int-card-text">
						<view class="name"><text>{{item.actName}}</text></view>
						<view><text>{{renderTime(item.startTime)}}-{{renderTime(item.endTime)}}</text></view>
						<view class="place"><text>{{item.museum.museAddr}}</text></view>
					</view>
					<view class="int-card-label">
						<view class="label" v-for=" item in item.actTag">{{item}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="hot" v-if="chooseIndex == 1">
			<view class="interest-card" v-for="(item,index) in hotAct">
				<view class="img"><image :src="item.actImg"></image></view>
				<view class="text">
					<view class="int-card-text">
						<view class="name"><text>{{item.actName}}</text></view>
						<view><text>{{renderTime(item.startTime)}}-{{renderTime(item.endTime)}}</text></view>
						<view class="place"><text>{{item.museum.museAddr}}</text></view>
					</view>
					<view class="int-card-label">
						<view class="label" v-for=" item in item.actTag">{{item}}</view>
					</view>
				</view>	
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		onLoad() {
			this.getNewAct(1,10,0);
			this.getHotAct(1,10,1);
			this.getType();
		},
		data(){
			return{
				
				chooseItems:['最新','最热'],
				chooseIndex:0,
				newAct:[],
				hotAct:[],
				type:[],
				act:[
					{
						id:1,
						acturl:"../../../static/swiper/1.jpg",
						actname:"灵感事务所",
						acttime:"2020.09.30-2020.12.31",
						actplace:"杭州  |  杭州天地二层L201"
					},
					{
						id:2,
						acturl:"../../../static/swiper/2.jpg",
						actname:"灵感事务所",
						acttime:"2020.09.30-2020.12.31",
						actplace:"杭州  |  杭州天地二层L201"
					},
					{
						id:3,
						acturl:"../../../static/swiper/3.jpg",
						actname:"灵感事务所",
						acttime:"2020.09.30-2020.12.31",
						actplace:"杭州  |  杭州天地二层L201"
					},
					{
						id:4,
						acturl:"../../../static/swiper/4.jpg",
						actname:"灵感事务所",
						acttime:"2020.09.30-2020.12.31",
						actplace:"杭州  |  杭州天地二层L201"
					}
				],
				label:["娱乐","美国","流行"]
			}
		},
		methods:{
			onClickItem(e) { 
				this.chooseIndex = e.currentTarget.id
			},
			//修改时间格式：年月日
			renderTime(date) {
			  var dateee = new Date(date).toJSON();
			  return new Date(+new Date(dateee) + 8 * 3600 * 1000)
						.toISOString()
						.replace(/T/g, ' ')
						.replace(/\.[\d]{3}Z/, '') 
						.replace(/-/g, ".")
						.substring(0, 10)
			},
			getNewAct(current,size,type){
				uni.request({
					url:"http://ronin.fun:8888/find/neworhot",
					data:{
						current:current,
						size:size,
						type:type
					},
					success: (res) => {
						this.newAct = res.data.data.records;
						console.log(this.newAct);
					}
				})
			},
			getHotAct(current,size,type){
				uni.request({
					url:"http://ronin.fun:8888/find/neworhot",
					data:{
						current:current,
						size:size,
						type:type
					},
					success: (res) => {
						this.hotAct = res.data.data.records;
						console.log(this.hotAct);
					}
				})
			},
			getType(){
				uni.request({
					url:"http://ronin.fun:8888/find/class",
					success: (res) => {
						this.type = res.data.data;
						console.log(this.type);
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.content{
		width: 100%;
		height: 100%;
		.act-type-choose{
		    width: 100%;
			height: 400rpx;
			background-color: white;
			display: flex;
			flex-direction: row;
			overflow-x: auto;
			.each-column{
				width: 170rpx;
				height: 100%;
				margin: 0;
				margin-left: 10rpx;
				margin-right: 10rpx;
				padding: 0;
				text-align: center;
				.each-one{
					width: 170rpx;
					height: 170rpx;
					display: flex;
					flex-direction: column;
					-webkit-box-align: center;
					align-items: center;
					margin-top: 10px;
					margin-bottom: 0;
					image{
							width: 120rpx;
							height: 120rpx;
							border-radius: 60rpx;
					}
					text{
							font-size: 16px;
							text-align: center;
							margin-top:3px;
					}
				}
			}
		}
		.act-type-choose::-webkit-scrollbar {
		    display: none;
		}
		.choose-new-hot{
			width: 100%;
			height: 100rpx;
			margin-top: 20rpx;
			.new-hot{
				margin-left: 30rpx;
				color: #555555;
				font-size: 40rpx;
				
			}
			.new-hot-active{
				margin-left: 30rpx;
				color: #B0E3FF;
				font-size: 50rpx;
				font-weight: bold;
			}
		}
		.interest-card{
			margin: 20rpx 30rpx 20rpx 30rpx;
			height: 440rpx;
			border-radius: 20rpx;
			box-shadow: 0px 2px 1px rgba(200,200,200,.30);
			.img{
				display: inline-block;
				image{
					margin: 10rpx 10rpx 10rpx 10rpx;
					width: 280rpx;
					height: 400rpx;
					border-radius: 20rpx;
				}
			}
			.text{
				display: inline-block;
				vertical-align: top;
				margin-top: 20rpx;
				.int-card-text{
					text-align: center;
					color: #797979;
					font-size: 30rpx;
					margin-top: 20rpx;
					line-height: 50rpx;
					margin-bottom: 20rpx;
					width: 380rpx;
					
					.name{
						text-align: center;
						color: #333333;
						font-weight: bold;
						font-size: 40rpx;
						line-height: 60rpx;
						margin-top: 20rpx;
						margin-bottom: 20rpx;
						overflow: hidden;
						-webkit-line-clamp: 2;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-box-orient: vertical;
					}
					.place{
						-webkit-line-clamp: 2;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-box-orient: vertical;
					}
				}
				.int-card-label{
					vertical-align: middle;
					margin-top: 20rpx;
					.label{
						width: 120rpx;
						height: 45rpx;
						display: inline-block;
						border: 1px solid #B0E3FF;
						color: #B0E3FF;
						border-radius: 20rpx;
						text-align: center;
					}
				}
			}
			
		}
	}
</style>
